<template>
  <div class="piao">
    <Navi :title="'我的电影票'" :flexd="true" />
    <div class="nav" v-show="isHas">
      <div class="box" v-for="(item, index) in params" :key="index">
        <div class="nbox">
          <div class="tbox">
            <div class="title">{{ item.params.title }}</div>
            <div class="time">
              时间：{{ item.params.dt }}-{{ item.params.tm }}
            </div>
            <div class="lei">类型：{{ item.params.lang }}</div>
            <div class="ting">放映厅：{{ item.params.th }}</div>
            <div class="wei" v-for="(e, i) in item.sum" :key="i">
              座位：{{ e }}
            </div>
          </div>
          <div class="sum">￥{{ item.params.price }} x {{ item.sum.length }}</div>
        </div>
      </div>
    </div>
    <div class="type" v-show="!isHas">
      <van-empty description="请先登录">
        <van-button @click="goLogin()" round type="danger" class="bottom-button">去登录</van-button>
      </van-empty>
    </div>
    <div class="bi" v-show="isLength">
      <van-empty description="请先购票" />
    </div>
  </div>
</template>

<script>
import Navi from "../components/Navi.vue";
export default {
  name: "Piao",
  components: {
    Navi,
  },
  data() {
    return {
      params: [],
      isHas: false,
      isLength:false,
    };
  },
  created() {
    let token = JSON.parse(localStorage.getItem("token") || "[]");
    
    if (token.length === 0) {
      
      this.isHas = false;
      this.isLength=false;
      return;
    } else {
      this.isHas = true;
      let loc = JSON.parse(localStorage.getItem("obj") || "[]");
      
      if(loc.length === 0){
        this.isLength=true;
        return
      }else{
        this.params = loc;
        this.isLength=false;
      }
      
    }
  },
  methods: {
    goLogin(){
      this.$router.push({ name: "Login" });
    }
  },
};
</script>

<style lang="less" scoped>

.nav {
  width: 100%;
  padding: 10px;
  box-sizing: border-box;
  .nbox {
    width: 100%;
    display: flex;
    justify-content: space-between;
    padding: 10px;
    box-sizing: border-box;
    border-radius: 10px;
    background-color: #fffafa;
    margin-bottom: 10px;
    .tbox {
      width: 50%;

      .title {
        font-size: 20px;
        color: #333;
        margin: 1px 0;
      }
      .time {
        font-size: 14px;
        color: #333;
      }
      .lei,
      .ting,
      .wei {
        font-size: 12px;
        color: #333;
        margin: 1px 0;
      }
    }
    .sum {
      width: 20%;
      font-size: 15px;
      color: #999;
      text-align: bottom;
      text-align: right;
      padding-top: 100px;
      box-sizing: border-box;
    }
  }
}
</style>